package com.yanqu.road.server.cmd.activity.musicroomrank;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.MusicRoomRankProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.musicroom.MusicRoomRankActivityModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_MUSIC_ROOM_RANK_JOIN_SHOW, desc = "妙音坊冲榜 历史比赛详情")
public class MusicRoomRankJoinShowCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        MusicRoomRankProto.MusicRoomRankJoinShowReqMsg reqMsg = MusicRoomRankProto.MusicRoomRankJoinShowReqMsg.parseFrom(packet.getBytes());
        ret = player.getModule(MusicRoomRankActivityModule.class).joinShow(reqMsg);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret > 0) {
            player.sendPacket(ClientProtocol.U_MUSIC_ROOM_RANK_JOIN_SHOW, MusicRoomRankProto.MusicRoomRankJoinShowRespMsg.newBuilder().setRet(ret));
        }
    }
}
